<HTML><HEAD>
<TITLE>netwib doc_html (version 5.39.0)</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A HREF="../../index.html">main index</A></H2>
<H2><A HREF="../pkt.html">section index</A></H2><HR><BR>
<PRE>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000"><B>/***************************************************************
 * Following functions create/decode layers. Their names       *
 * should be self explaining.                                  *
 * Note : when decoding a layer, ppkt buffer is automatically  *
 *        shifted to point to next entry.                      *
 ***************************************************************/</B></FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000"><B>/***************************************************************
 * Some header fields are computed by functions append_layer:  *
 *  - linkhdr.ethhdr.type                                      *
 *  - iphdr.protocol                                           *
 *  - iphdr.header.ip4.ihl                                     *
 *  - iphdr.header.ip4.totlen                                  *
 *  - iphdr.header.ip4.check                                   *
 *  - iphdr.header.ip6.payloadlength                           *
 *  - udphdr.len                                               *
 *  - udphdr.check                                             *
 *  - tcphdr.doff                                              *
 *  - tcphdr.check                                             *
 *  - icmp4hdr.check                                           *
 * To use fake values for those fields, they have to be edited *
 * after packet construction.                                  *
 ***************************************************************/</B></FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000"><B>/***************************************************************
 * Which functions to use ?                                    *
 *                                                             *
 * Netwib has 3 kind of functions to decode packets:           *
 *  - <FONT COLOR="#000088">netwib_pkt_decode_abc</FONT> ie <FONT COLOR="#000088">netwib_pkt_decode_iphdr</FONT>         *
 *  - <FONT COLOR="#000088">netwib_pkt_decode_layer_abc</FONT> ie netwib_pkt_decode_layer_ip*
 *  - netwib_pkt_decode_abcABC ie <FONT COLOR="#000088">netwib_pkt_decode_iptcp</FONT>      *
 * Functions <FONT COLOR="#000088">netwib_pkt_decode_abc</FONT> and                         *
 * <FONT COLOR="#000088">netwib_pkt_decode_layer_abc</FONT> are almost equivalent.          *
 * Functions netwib_pkt_decode_abcABC permits to decode only   *
 * one kind of protocol : ABC on top of abc. So, they can only *
 * be used in simple cases.                                    *
 *                                                             *
 * Netwib has 3 kind of functions to create packets:           *
 *  - <FONT COLOR="#000088">netwib_pkt_append_abc</FONT> ie <FONT COLOR="#000088">netwib_pkt_append_iphdr</FONT>         *
 *  - <FONT COLOR="#000088">netwib_pkt_append_layer_abc</FONT> ie netwib_pkt_append_layer_ip*
 *  - netwib_pkt_append_abcABC ie <FONT COLOR="#000088">netwib_pkt_append_iptcp</FONT>      *
 * Functions <FONT COLOR="#000088">netwib_pkt_append_abc</FONT> use exact fields given as   *
 * parameters from users.                                      *
 * Functions <FONT COLOR="#000088">netwib_pkt_append_layer_abc</FONT> compute fields before *
 * storing them in the packet.                                 *
 * Functions netwib_pkt_append_abcABC permits to create only   *
 * one kind of protocol : ABC on top of abc. So, they can only *
 * be used in simple cases.                                    *
 *                                                             *
 * Summary: when possible, use netwib_pkt_append/decode_layer  *
 *          which are :                                        *
 *           - easier than netwib_pkt_append/decode_abc        *
 *             because they compute fields                     *
 *           - faster than netwib_pkt_append/decode_abcABC     *
 *             if several protocols of the same layer have to  *
 *             be decoded (for example : iptcp and ipudp)      *
 ***************************************************************/</B></FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_data</B>(<FONT COLOR="#000088">netwib_constbuf</FONT> *pdata,
                                        <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_data</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                        <FONT COLOR="#000088">netwib_bufext</FONT> *pdata);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_link</B>(<FONT COLOR="#000088">netwib_constlinkhdr</FONT> *plinkhdr,
                                        <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_link</B>(<FONT COLOR="#000088">netwib_device_dlttype</FONT> dlttype,
                                        <FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                        <FONT COLOR="#000088">netwib_linkhdr</FONT> *plinkhdr);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_ip</B>(<FONT COLOR="#000088">netwib_constiphdr</FONT> *piphdr,
                                      <FONT COLOR="#000088">netwib_uint32</FONT> datasize,
                                      <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_ip</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                      <FONT COLOR="#000088">netwib_iphdr</FONT> *piphdr);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* fields followed by "checksum" are needed only for checksum
   computation */</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_udp</B>(<FONT COLOR="#000088">netwib_constiphdr</FONT> *piphdr,<FONT COLOR="#880000">/*checksum*/</FONT>
                                       <FONT COLOR="#000088">netwib_constudphdr</FONT> *pudphdr,
                                       <FONT COLOR="#000088">netwib_constbuf</FONT> *pudpdata,<FONT COLOR="#880000">/*checksum*/</FONT>
                                       <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_udp</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                       <FONT COLOR="#000088">netwib_udphdr</FONT> *pudphdr);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_tcp</B>(<FONT COLOR="#000088">netwib_constiphdr</FONT> *piphdr,<FONT COLOR="#880000">/*checksum*/</FONT>
                                       <FONT COLOR="#000088">netwib_consttcphdr</FONT> *ptcphdr,
                                       <FONT COLOR="#000088">netwib_constbuf</FONT> *ptcpdata,<FONT COLOR="#880000">/*checksum*/</FONT>
                                       <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_tcp</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                       <FONT COLOR="#000088">netwib_tcphdr</FONT> *ptcphdr);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_icmp4</B>(<FONT COLOR="#000088">netwib_consticmp4</FONT> *picmp4,
                                         <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_icmp4</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                         <FONT COLOR="#000088">netwib_icmp4</FONT> *picmp4);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_icmp6</B>(<FONT COLOR="#000088">netwib_constiphdr</FONT> *piphdr,
                                         <FONT COLOR="#000088">netwib_consticmp6</FONT> *picmp6,
                                         <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_icmp6</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                         <FONT COLOR="#000088">netwib_icmp6</FONT> *picmp6);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_append_layer_arp</B>(<FONT COLOR="#000088">netwib_constarphdr</FONT> *parphdr,
                                       <FONT COLOR="#000088">netwib_buf</FONT> *ppkt);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_pkt_decode_layer_arp</B>(<FONT COLOR="#000088">netwib_buf</FONT> *ppkt,
                                       <FONT COLOR="#000088">netwib_arphdr</FONT> *parphdr);
</PRE><BR><BR><HR><BR>
<H2><A HREF="../../index.html">main index</A></H2>
<H2><A HREF="../pkt.html">section index</A></H2>
</BODY></HTML>
